<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <div>
            <button @click="abc='mycom1'">组件一</button>
            <button @click="abc='mycom2'">组件二</button>
        </div>
        <component :is="abc">

        </component>


    </div>
    <script>
        var component1 ={
            template:`
            <div>
            <p>我是组件一</p>    
            </div>
            `,
        }
        var component2 ={
            template:`
            <div>
            <p>我是组件二</p>    
            </div>
            `,
        }

        var vm = new Vue({
            el: '#app',
            data: {
                abc:'mycom1' 
            },
            methods: {},
            components:{
                mycom1:component1,
                mycom2:component2,
            }

        })
    </script>
</body>

</html>